package ml2;

import java.util.Random;

public class StarBag {
	private final double [] _x;
	private final double [] _y;
	private final double [] _mass;

	public StarBag(int n, double sizeX, double sizeY){
		_x = new double[n];
		_y = new double[n];
		_mass = new double[n];
		Random generator = new Random(10061995L);
		for (int i=0;i<n;i++){
			_x[i] = sizeX * (generator.nextDouble() - 0.5);
			_y[i] = sizeY * (generator.nextDouble() - 0.5);
			_mass[i] = 1.0;
		}
	}

	public StarBag(double[] xStar, double[] yStar) {
		int n = xStar.length;
		_x = new double[n];
		_y = new double[n];
		_mass = new double[n];

		for (int i=0;i<n;i++){
			_x[i] = xStar[i];
			_y[i] = yStar[i];
			_mass[i] = 1.0;
		}
	}

	public Double[] getPos(int i){
		return new Double[] {_x[i], _y[i], _mass[i]};
	}

	public double[] getXArray(){
		return _x;
	}
	public double[] getYArray(){
		return _y;
	}
	public double[] getMassArray(){
		return _mass;
	}

	public int size() {
		return _x.length;
	}

	public double getX(int i) {
		return _x[i];
	}

	public double getY(int i) {
		return _y[i];
	}
}
